#ifndef _DAL_USER_H_
#define _DAL_USER_H_
#ifdef __cplusplus
extern "C" {
#endif

#include "sal.h"

#define sal_poll        poll
#define sal_pollfd      pollfd


#define   CHECK_FD(fd)                    if (fd < 0) return -999
#define CHECK_PTR(ptr)                  if (!ptr) return -1000


#define DAL_INTR_POLL_TIMEOUT  2000       
#define DAL_MAX_INTR_NUM    4

#define DAL_INTR_DEV_NAME "/dev/dal_intr"  /* [GB] */

#define SAL_STACK_SIZE 128*1024

#define GPIO0 1
#define GPIO1 3
#define GPIO2 4
#define GPIO3 5

struct intr_handler_s
{
    sal_task_t*  p_intr_thread;
    int irq;
    void* data;
    void (* handler)(void*);
};
typedef struct intr_handler_s intr_handler_t;

struct dal_intr_para_s
{
    unsigned char irq;
    char intr_idx;
};
typedef struct dal_intr_para_s dal_intr_para_t;

struct dal_op_s
{
	 int   (* init)();
	 int   (* exit)();
    int   (* interrupt_register)(unsigned int irq, unsigned int prio,void (*)(void*), void* data);
    int   (* interrupt_unregister)(unsigned int irq);
    int   (* interrupt_set_en)(unsigned int irq, unsigned int enable);
};
typedef struct dal_op_s dal_op_t;

extern int dal_usr_init();
extern int dal_usr_exit();
extern int dal_interrupt_register(unsigned int irq, unsigned int prio,void (* isr)(void*), void* data);
extern int dal_interrupt_unregister(unsigned int irq);
extern int dal_interrupt_set_en(unsigned int irq, unsigned int enable);

#ifdef __cplusplus
}
#endif

#endif

